package com.hu.zhcc.shiro.controller;

import com.github.pagehelper.PageInfo;
import com.hu.zhcc.shiro.entity.bo.CheckMind;
import com.hu.zhcc.shiro.entity.vo.CheckMindVO;
import com.hu.zhcc.shiro.service.CheckMindService;
import com.hu.zhcc.shiro.service.CheckMindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 体质评估
 */

@RestController
@CrossOrigin
@RequestMapping("/checkmind")
public class CheckMindController {
    @Autowired
    private CheckMindService checkMindService;

    @GetMapping("")
    @ResponseBody
    public PageInfo<CheckMind> homeCheckMind(CheckMindVO checkMindVO){
        PageInfo<CheckMind> checkMindPageInfo = checkMindService.pageQuery(checkMindVO);
        return checkMindPageInfo;
    }

    @PostMapping("")
    public ResponseEntity<?> saveCheckitem(@RequestBody CheckMind checkMind) {
        return checkMindService.AddMind(checkMind) ? ResponseEntity.noContent().build() :
                ResponseEntity.notFound().build();
    }
    @DeleteMapping("/{id}")
    public ResponseEntity<?> removeCheckMind(@PathVariable("id") Short id) {
        return checkMindService.removeMind(id) ? ResponseEntity.noContent().build() :
                ResponseEntity.notFound().build();
    }

    @PutMapping("/{id}")
    public ResponseEntity<Integer> updateRouter(@PathVariable("id") int id, @RequestBody CheckMind checkMind) {
        return checkMindService.updateMind(checkMind) ? ResponseEntity.noContent().build() :
                ResponseEntity.notFound().build();
    }
}
